package cn.liujianbo.example.pattern.decorator;

/**
 * @author 刘建波
 * @date 2022-03-04 13:59
 */
public class DecoratorTest {
    public static void main(String[] args) {
        FastFood friedNoodles = new FriedNoodles();
        System.out.println("顾客1点了 【" + friedNoodles.getName() + "】 应付：" + friedNoodles.cost());

        friedNoodles = new FriedRice();
        System.out.println("顾客2点了 【" + friedNoodles.getName() + "】 应付：" + friedNoodles.cost());

        friedNoodles = new FriedNoodles();
        friedNoodles = new EggDecorator(friedNoodles);
        System.out.println("顾客3点了 【" + friedNoodles.getName() + "】 应付：" + friedNoodles.cost());


        friedNoodles = new FriedNoodles();
        friedNoodles = new EggDecorator(friedNoodles);
        friedNoodles = new BaconDecorator(friedNoodles);
        System.out.println("顾客4点了 【" + friedNoodles.getName() + "】 应付：" + friedNoodles.cost());

        friedNoodles = new FriedRice();
        friedNoodles = new EggDecorator(friedNoodles);
        System.out.println("顾客5点了 【" + friedNoodles.getName() + "】 应付：" + friedNoodles.cost());

        friedNoodles = new FriedRice();
        friedNoodles = new EggDecorator(friedNoodles);
        friedNoodles = new BaconDecorator(friedNoodles);
        System.out.println("顾客4点了 【" + friedNoodles.getName() + "】 应付：" + friedNoodles.cost());
    }
}
